package com.lvwenguo.controller.category;

import com.lvwenguo.service.CategoryListServiceInter;
import com.lvwenguo.service.serviceImple.CategoryListServiceImple;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//删除品类信息
@WebServlet(urlPatterns = "/deleteCategory")
public class deleteCategory extends HttpServlet {
    CategoryListServiceInter categoryListServiceImpol =new CategoryListServiceImple();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        System.out.println(id);
        int i = categoryListServiceImpol.deleteCategory(Integer.parseInt(id));
        if(i!=0){
            req.getRequestDispatcher("/CategoryListServlet").forward(req,resp);
        }else{
            req.getRequestDispatcher("/CategoryListServlet").forward(req,resp);
        }

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
